package edu.uoc.tdp.pac4.client.logandreg;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import edu.uoc.tdp.pac4.common.util.LanguageUtils;



public class StudentRegStatusModel extends AbstractTableModel{
	

	private static final long serialVersionUID = 1L;
	protected Vector<String> listHeaders = new Vector<String>();
	protected List<RegistrationData> regs = new ArrayList<RegistrationData>();
	
	
	public StudentRegStatusModel(List<RegistrationData> regsList) {
		setHeader();
		regs = regsList;
	}

	
	protected void setHeader() {
		listHeaders.add(LanguageUtils.getMessage("client.regandlog.table.header.title1"));
		listHeaders.add(LanguageUtils.getMessage("client.regandlog.table.header.title2"));
		listHeaders.add(LanguageUtils.getMessage("client.regandlog.table.header.title3"));
		listHeaders.add(LanguageUtils.getMessage("client.regandlog.table.header.title4"));
		listHeaders.add(LanguageUtils.getMessage("client.regandlog.table.header.title5"));
	}

	
	public String getColumnName(int col) {
		return ((String) listHeaders.get(col));
	}

	public int getColumnCount() {
		return listHeaders.size();
	}

	public int getRowCount() {
		if (regs != null)
			return regs.size();
		else
			return 0;
	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		RegistrationData res = null;
		if (regs != null) {
			res = (RegistrationData) regs.get(rowIndex);

			switch (columnIndex) {
			case 0:
				return res.getCoursename();
			case 1:
				return res.getGroupname();
			case 2:
				return res.getStartDate();
			case 3:
				return res.getEndDate();
			case 4:
				return res.getStatus();
			}
		}
		return res;
	}
	
	public boolean isCellEditable(int row, int column) {
		return (false);
	}
}
